package com.lyon.custom.parse;

import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * @author LeeYan9
 * @since 2021-11-26
 */
@Slf4j
@SuppressWarnings("all")
public abstract class AbstractDataParseProcessor implements LyonDataParseProcessor {

    @Override
    public Map<String, String> parse(String content) {
        Map<String, String> result = null;
        try {
            if (StrUtil.isNotBlank(supportType())) {
                log.info("准备解析数据..");
                result = doParseData(content);
                log.info("解析完成...");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result == null ? MapUtil.empty() : result;
    }

    /**
     * 解析
     *
     * @param content 内容
     * @return 结果
     */
    protected abstract Map<String, String> doParseData(String content);
}
